/* Create list of univ surrounding counties for reference.

*/

clear
clear matrix
capture log close
set more off

log using "select_analysis_areas_mylog.log", replace


global path ""
global p1069 "" 
global lbd ""
global lbd_naics ""
global xwalks ""
global data_from_sas ""
global imported_data ""
global inter ""
global output_data ""
global programs ""
global out ""

use ${imported_data}county_dists.dta, clear


preserve
   keep if fice==1218 & surstcntyfips==6037
   replace surstcntyfips=6071
   replace centdist=.
   replace edgedist=.
   replace stfips_sur = stfips_cont
   replace cntyname_sur=""
   save ${inter}owncounty1.dta, replace
restore
preserve
   keep if fice==2568 & surstcntyfips==32029
   replace surstcntyfips=32031
   replace centdist=.
   replace edgedist=.
   replace stfips_sur = stfips_cont
   replace cntyname_sur=""
   save ${inter}owncounty2.dta, replace
restore

append using ${inter}owncounty1.dta
append using ${inter}owncounty2.dta
save ${inter}countydists_plustwo.dta, replace

contract surstcntyfips
drop _freq
sort surstcntyfips
save ${inter}countylist.dta, replace

use ${inter}countydists_plustwo.dta, clear

replace strzip="" if strzip=="0"
destring strzip, replace
replace numzip = strzip if numzip==. & strzip!=.
drop strzip

keep univsysname univsysnum contstcntyfips surstcntyfips 

save ${inter}univ_counties.dta, replace


log close














